<!--
  ~ Copyright (c) [2019] [lookang]
  ~    [Software Name] is licensed under the Mulan PSL v1.
  ~    You can use this software according to the terms and conditions of the Mulan PSL v1.
  ~    You may obtain a copy of Mulan PSL v1 at:
  ~       http://license.coscl.org.cn/MulanPSL
  ~    THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR
  ~    IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR
  ~    PURPOSE.
  ~    See the Mulan PSL v1 for more details.
  -->

<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="layui/css/layui.css" media="all">
    <script type="text/javascript" src="jquery/jquery-1.11.1.min.js"></script>
    <!--    <script src="layui/layui.js"></script>-->
    <script src="layui/layui.all.js"></script>
    <title>主页</title>
</head>
<body background="picture/bg.jpg">

<div align="right">
    <button type="button" class="layui-btn layui-btn-radius layui-btn-normal loginBtn">登陆定制专属菜单</button>
    <button type="button" class="layui-btn layui-btn-radius layui-btn-normal registerBtn">注册</button>
</div>

<div align="center">
    <button type="button" class="layui-btn layui-btn-radius layui-btn-normal choiceFoodBtn"></button>
</div>
</body>
<script type="text/javascript">
    var layer;
    layui.use('layer', function () {
        layer = layui.layer;
    });
    $(function () {
        var btn = $('.choiceFoodBtn');
        btn.css('text-align', 'center');

        var btnText,mealsFlag;
        var curDate = new Date().getHours();
        console.log(curDate);

        if (curDate > 5 && curDate <= 10) {
            btnText = "看看早上吃什么";
            mealsFlag = 0;
        } else if (curDate > 10 && curDate <= 14) {
            btnText = "看看中午吃什么";
            mealsFlag = 1;
        } else if (curDate > 14 && curDate <= 21) {
            btnText = "看看晚上吃什么";
            mealsFlag = 2;
        } else {
            btnText = "看看夜宵吃什么";
            mealsFlag = 3;
        }

        btn.text(btnText);

        $('.choiceFoodBtn').on('click', function () {
            $.ajax({
                type: 'GET',
                url: 'choiceFood?mealsFlag='+mealsFlag+'&d=' + new Date(),
                success: function (result) {
                    layer.alert(result);
                }
            });
        });
        $('.loginBtn').on('click', function () {

        });
    })
    
    function login() {

    }

</script>
</html>